package com.ww.java8.fp.stream.inaction.ch05;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.ww.java8.fp.stream.inaction.ch04.Dish;

/**
 * 过滤器
 * @author wanggw
 * 2023年11月8日 下午4:01:01
 */
public class Filtering {

	public static void main(String[] args) {
		List<Dish> vegetarianMenu = Dish.menu.stream()
		.filter(Dish::isVegetarian)
		.collect(Collectors.toList());
		vegetarianMenu.forEach(System.out::println);
		
		List<Integer> numbers = Arrays.asList(1, 2, 3, 1, 2, 4, 1);
		numbers.stream()
		.filter(i -> 0 == i % 2)
		.distinct()
		.forEach(System.out::println);
	}
}
